/* const Koa = require('koa');
const Router = require('koa-router');
const app = new Koa();
const router = new Router();

router.get('/', function(ctx,next){
	ctx.body = 'Hello CJTY!';
});
 
app
.use(router.routes())
// .use(router.allowedMethods());
//处理的业务是当所有路由中间件执行完成之后,若ctx.status为空或者404的时候,丰富response对象的header头.
app.listen(3000, ()=>{
	console.log('[demo] server is starting at port 3000');
}) */

const Koa = require('koa');
const Router = require('koa-router');

const app = new Koa();
// const router = new Router();
const router = new Router({ //访问路径就加了一个层级jspang
      prefix:'/cjty'
})
router.get('/', function (ctx, next){
	ctx.body = "Hello CJTY";
})
.get('/todo', function(ctx, next){ //加入页面配置
	ctx.body = "Todo page"
});

app
.use(router.routes())
.use(router.allowedMethods());

app.listen(3000, ()=>{
	console.log('[demo] server is starting at port 3000');
})